import { getObjValue, setObjValue } from "./common";
export function getInitVals(layConf, type, defaultValue) {
  var iv;
  if (layConf && layConf.children) {
    switch (type) {
      case 'form':
        {
          iv = defaultValue || {};
          var loop = function loop(items) {
            items.forEach(function (item) {
              if (item.xtype === 'container') {
                loop(item.items || item.children || []);
              } else if (item.name && item.hasOwnProperty('defaultValue') && getObjValue(iv, item.name) === void 0) {
                setObjValue(iv, item.name, item.defaultValue);
              }
            });
          };
          loop((layConf === null || layConf === void 0 ? void 0 : layConf.children) || []);
          break;
        }
      case 'grid':
        iv = defaultValue || [];
        break;
      default:
        iv = {};
    }
  }
  return iv;
}